package handle

import (
	"context"
	"embed"
	_ "embed"

	"github.com/cloudwego/hertz/pkg/app"
	"github.com/cloudwego/hertz/pkg/app/server"
)

func NewStatic() Static {
	return Static{}
}

type Static struct {
}

//go:embed static
var static embed.FS

func (r Static) InitRoute(server *server.Hertz) {
	server.StaticFS("/static", &app.FS{
		Root:               "/home/debi/IdeaProjects/LearnGo/web/hertzx/route/",
		GenerateIndexPages: true,
		Compress:           false,
		AcceptByteRange:    false,
	})
	//server.GET("/static", r.Static())
}

func (r Static) Static() app.HandlerFunc {
	return func(c context.Context, ctx *app.RequestContext) {
		//router.StaticFS("/using_static", &app.FS{Root: dir, AcceptByteRange: true, PathRewrite: app.NewPathSlashesStripper(1)})
		//router.StaticFile("/result", f.Name())
	}
}
func (r Static) Index() app.HandlerFunc {
	return func(c context.Context, ctx *app.RequestContext) {
		//router.StaticFS("/using_static", &app.FS{Root: dir, AcceptByteRange: true, PathRewrite: app.NewPathSlashesStripper(1)})
		//router.StaticFile("/result", f.Name())
		ctx.File("/home/debi/IdeaProjects/LearnGo/web/hertzx/route/index.html")
	}
}
